// ProductA 和 ProductB 接口
interface ProductA {
    void use();
}

interface ProductB {
    void use();
}

// ConcreteProductA1 和 ConcreteProductA2 类
class ConcreteProductA1 implements ProductA {
    public void use() {
        System.out.println("ConcreteProductA1 use");
    }
}

class ConcreteProductA2 implements ProductA {
    public void use() {
        System.out.println("ConcreteProductA2 use");
    }
}

// ConcreteProductB1 和 ConcreteProductB2 类
class ConcreteProductB1 implements ProductB {
    public void use() {
        System.out.println("ConcreteProductB1 use");
    }
}

class ConcreteProductB2 implements ProductB {
    public void use() {
        System.out.println("ConcreteProductB2 use");
    }
}

// AbstractFactory 接口
interface AbstractFactory {
    ProductA createProductA();
    ProductB createProductB();
}

// ConcreteFactory1 和 ConcreteFactory2 类
class ConcreteFactory1 implements AbstractFactory {
    public ProductA createProductA() {
        return new ConcreteProductA1();
    }
    public ProductB createProductB() {
        return new ConcreteProductB1();
    }
}

class ConcreteFactory2 implements AbstractFactory {
    public ProductA createProductA() {
        return new ConcreteProductA2();
    }
    public ProductB createProductB() {
        return new ConcreteProductB2();
    }
}

// 测试类
public class AbstractFactoryTest {
    public static void main(String[] args) {
        AbstractFactory factory1 = new ConcreteFactory1();
        ProductA productA1 = factory1.createProductA();
        ProductB productB1 = factory1.createProductB();
        productA1.use();
        productB1.use();

        AbstractFactory factory2 = new ConcreteFactory2();
        ProductA productA2 = factory2.createProductA();
        ProductB productB2 = factory2.createProductB();
        productA2.use();
        productB2.use();
    }
}